package pro.cherish.knowledgeumldesignpattern.designPattern.com.cherish.decorator;

/**
 * 抽像组件
 */
public interface ICar {
    void move();
}

//具体构建对象（真实对象）
class Car implements  ICar{
    @Override
    public void move() {
        System.out.println("陆地上跑");
    }
}
//Decorator 装饰角色
class SupperCar implements ICar{

    protected ICar car;

    public SupperCar(ICar car) {
        super();
        this.car = car;
    }

    @Override
    public void move() {
        car.move();
    }
}

//具体装饰对象
class FlyCar extends  SupperCar{

    public FlyCar(ICar car) {
        super(car);
    }
    public void fly(){
        System.out.println("天上飞");
    }

    @Override
    public void move() {
        super.move();
        fly();
    }
}
//具体装饰对象
class WaterCar extends  SupperCar {

    public WaterCar(ICar car) {
        super(car);
    }

    public void swim() {
        System.out.println("水上游");
    }
    @Override
    public void move() {
        super.move();
        swim();
    }
}

//具体装饰对象
class AiCar extends  SupperCar {

    public AiCar(ICar car) {
        super(car);
    }

    public void autoMove() {
        System.out.println("自动跑");
    }

    @Override
    public void move() {
        super.move();
        autoMove();
    }
}